const http = require('http');
const fs = require('fs');
const resUtil = require('./response-util')

const server = http.createServer()

server.on('request', function (req, res) {
    if (req.url == '/' || req.url == './天亮云课堂项目/天亮云课堂首页.html') {
        console.log(123)
        resUtil.htmlResponse('./天亮云课堂项目/天亮云课堂首页.html', res)
    } else if (req.url == '/css/index.css') {
        console.log(000)
        resUtil.htmlResponse('./天亮云课堂项目/css/index.css', res)
    } else if (req.url == '/css/main.css') {
        console.log(000)
        resUtil.htmlResponse('./天亮云课堂项目/css/main.css', res)
    } else if (req.url == '/js/jquery-1.11.1.min.js') {
        console.log('aaa')
        resUtil.htmlResponse('./天亮云课堂项目/js/jquery-1.11.1.min.js', res)
    } else if (req.url == '/js/index.js') {
        console.log('aaa')
        resUtil.htmlResponse('./天亮云课堂项目/js/index.js', res)
    } else if (req.url == '/images/bigImage.png') {
        console.log('bbb')
        resUtil.htmlResponse('./天亮云课堂项目/images/bigImage.png', res)
    } else if (req.url == '/images/bigImage2.png') {
        console.log('ccc')
        resUtil.htmlResponse('./天亮云课堂项目/images/bigImage2.png', res)
    } else if (req.url == '/images/bigImage3.png') {
        console.log('ddd')
        resUtil.htmlResponse('./天亮云课堂项目/images/bigImage3.png', res)
    } else if (req.url == '/images/bigImage4.png') {
        console.log('eee')
        resUtil.htmlResponse('./天亮云课堂项目/images/bigImage4.png', res)
    } else if (req.url == '/images/zhobo1.png') {
        console.log('eee')
        resUtil.htmlResponse('./天亮云课堂项目/images/zhobo1.png', res)
    } else {
        res.setHeader('Content-Type', "text/plain;charset=utf-8")
        res.end('404,您请求的页面不存在')
    }
})

server.listen(3500, function () {
    console.log('服务启动在3500端口')
})